package com.zysc.processflow.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zysc.processflow.entity.Organization;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zysc.processflow.entity.Person;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 组织机构表 Mapper 接口
 * </p>
 *
 * @author 正元智慧城市_
 * @since 2022-11-18
 */
@Repository
public interface OrganizationMapper extends BaseMapper<Organization> {

    @Select("SELECT a.* from organization a where a.code = #{tyshxydm} and a.type = '1' and a.isdel = '0' limit 1 ")
    Organization getOrgByTyshxydm(@Param("tyshxydm") String tyshxydm);

    List<Organization> getOrgDataListByKeyword(IPage<Organization> page, List<String> queryColomnList, String keyword);

    @Select("select * from organization")
    List<Organization> getTestOrganization();

    List<Organization> getOrgDataListByKeywordPrecise(IPage<Organization> page, List<String> queryColomnList, String keyword);
    @Select("SELECT a.* from organization a where a.code = #{tyshxydm} and a.type = '1' limit 1")
    Organization getOrganizationFromAll(@Param("tyshxydm")String tyshxydm);

    @Select("SELECT a.* from organization a where a.id = #{id} limit 1")
    Organization getOrganizationByIdFromAll(@Param("id")String id);

    @Select("SELECT a.* from organization a where a.code = #{code} and a.type = '11'")
    List<Organization> getOrgChildrenFromAll(@Param("code")String code);

    @Update("update organization  set isdel = #{flag} where id = #{orgid}")
    void setIsDelByOrgId(@Param("orgid")String orgid, @Param("flag")int flag);
}
